package connectors;

import utils.SynapseRandomizer;

import components.LIFNeuron;
import components.Synapse;

public class Connect {
	
	private SynapseRandomizer eeSR;
	private SynapseRandomizer eiSR;
	private SynapseRandomizer ieSR;
	private SynapseRandomizer iiSR;
	
	protected Synapse [][] weightMatrix;
	
	private boolean UDFon;
	
	private double cProb;
	
	public Connect(SynapseRandomizer eeSR, SynapseRandomizer eiSR,
			SynapseRandomizer ieSR, SynapseRandomizer iiSR) {
		this.eeSR = eeSR;
		this.eiSR = eiSR;
		this.ieSR = ieSR;
		this.iiSR = iiSR;
	}
	
	public Connect(){}
	
	public Synapse [][] flatConnect(double sparsity, LIFNeuron [] src,
			LIFNeuron [] targ) {
	
		weightMatrix = new Synapse[src.length][targ.length];
		int i = 0;
		int j;
		for(LIFNeuron s : src) {
			j = 0;
			for (LIFNeuron t : targ) {
				if(s != t && Math.random() < sparsity){
					Synapse syn = new Synapse(s, t);
					syn.setUDFon(UDFon);
					if(s.isExcitatory()){
						if(t.isExcitatory())
							eeSR.randomizeSynapse(syn);
						else
							eiSR.randomizeSynapse(syn);
					} else {
						if(t.isExcitatory())
							ieSR.randomizeSynapse(syn);
						else
							iiSR.randomizeSynapse(syn);
					}
					weightMatrix[i][j] = syn;
				}
				j++;
			}
			i++;
		}
		return weightMatrix;
	}
	
	public SynapseRandomizer getEeSR() {
		return eeSR;
	}
	public void setEeSR(SynapseRandomizer eeSR) {
		this.eeSR = eeSR;
	}
	public SynapseRandomizer getEiSR() {
		return eiSR;
	}
	public void setEiSR(SynapseRandomizer eiSR) {
		this.eiSR = eiSR;
	}
	public SynapseRandomizer getIeSR() {
		return ieSR;
	}
	public void setIeSR(SynapseRandomizer ieSR) {
		this.ieSR = ieSR;
	}
	public SynapseRandomizer getIiSR() {
		return iiSR;
	}
	public void setIiSR(SynapseRandomizer iiSR) {
		this.iiSR = iiSR;
	}

	public boolean isUDFon() {
		return UDFon;
	}

	public void setUDFon(boolean uDFon) {
		UDFon = uDFon;
	}
	
	public double getcProb() {
		return cProb;
	}

	public void setcProb(double cProb) {
		this.cProb = cProb;
	}
	

}
